import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'

Vue.use(Router)

// 开发环境不使用懒加载, 因为懒加载页面太多的话会造成webpack热更新太慢, 所以只有生产环境使用懒加载
const _import = require('./import-' + process.env.NODE_ENV)

const mainRoutes = [
  {
    path: '/',
    component: _import('main'),
    name: 'main',
    redirect: { name: 'home' },
    meta: { title: '主入口整体布局' },
    children: [
      // 通过meta对象设置路由展示方式
      // 1. isTab: 是否通过tab展示内容, true: 是, false: 否
      // 2. iframeUrl: 是否通过iframe嵌套展示内容, '以http[s]://开头': 是, '': 否
      // 提示: 如需要通过iframe嵌套展示内容, 但不通过tab打开, 请自行创建组件使用iframe处理!
      { path: '/', component: HelloWorld, name: 'HelloWorld' },
      { path: '/home', component: _import('common/home'), name: 'home', meta: { title: '首页' } },
      { path: '/activiti/model', component: _import('activiti/model'), name: 'activiti-model', meta: { title: '模型', isTab: true } },
      { path: '/activiti/process', component: _import('activiti/process'), name: 'activiti-process', meta: { title: '流程', isTab: true } },
      { path: '/activiti/detail/:id', component: _import('activiti/detail'), name: 'activiti-detail', meta: { title: 'detail' } },
      { path: '/activiti/task', component: _import('activiti/task'), name: 'activiti-task', meta: { title: '任务', isTab: true } }
    ]
  }
]

export default new Router({
  routes: mainRoutes
})
